const getAddressList = () => {
	return new Promise((resolve, reject) => {
		const url = 'https://apis.map.qq.com/ws/district/v1/list'
		const data = {
			key: 'FH4BZ-4HGKW-QU3RR-OTVDU-5AJZ3-UZBSP',
			output: 'jsonp',
			callback: 'getAddressCallback'
		}
		const script = document.createElement('script')
		script.type = 'text/javascript'
		script.async = true
		script.src =
			url +
			'?' +
			Object.keys(data)
				.map((key, idx) => key + '=' + data[key])
				.join('&')
		script.onerror = reject
		document.body.appendChild(script)
		window.getAddressCallback = res => {
			resolve(res.result)
		}
	})
}
export { getAddressList }


// async getAddressList() {
//     const res = await getAddressList()
//     console.log('getAddressList-->', res)
//     const provinceList = res[0]
//     const citys = {};
//     const sumCitys = res[1]
//     this.sumCitys = sumCitys;

//     provinceList.map((item,i) => {
//         const { cidx } = item
//         const cityList = sumCitys.slice(cidx[0], cidx[1])
//         cityList.map((item, i) => cityList[i] = item.name)
//         cityList.unshift("全部")
//         citys[item.name] = cityList;
//         provinceList[i] = item.name;
//     })
//     provinceList.unshift("全部");
//     console.log("provinceList>", provinceList)
//     this.provinceList = provinceList;
//     console.log("citys>", citys)
//     this.citys = citys;
// },